package com.hc.accountservice.web;

import com.hc.accountservice.service.AccountService;
import com.hc.entity.PayRecord;
import com.hc.entity.Wallet;
import com.hc.utils.ResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @BelongsProject: hc
 * @BelongsPackage: com.hc.accountservice.web
 * @Author: WY
 * @CreateTime: 2022-10-19  19:54
 * @Descriprion: TODO
 * @Version: 1.0
 **/
@RestController
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private AccountService accountService;

    //查看支付记录
    @GetMapping("/check")
    public ResponseEntity check(@RequestBody PayRecord payRecord){
        List<PayRecord> payRecords = accountService.findByPage(payRecord);
        return new ResponseEntity("200","ok",payRecords);
    }

    @GetMapping("/balance")
    public ResponseEntity balance(@RequestBody Wallet wallet){
        wallet = accountService.findBalance(wallet.getUserId());
        return new ResponseEntity("200","OK",wallet);
    }

}
